package com.example.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.constraints.NotNull;

/**
 * Created by xiaoyuan on 2017/8/9.
 */
@Controller
public class MyController {
    @RequestMapping("/user")
    public ModelAndView getUser(String username) {
        ModelAndView modelAndView = new ModelAndView("/index");
        modelAndView.addObject("username", username);
        return modelAndView;
    }

    @RequestMapping(value = "/uid/{uid}/did/{did}/nation/{nation}/city/{city}")
    public ModelAndView query(@PathVariable @NotNull String uid, @PathVariable @NotNull String did,
                              @PathVariable @NotNull String nation, @PathVariable @NotNull String city) {
        ModelAndView modelAndView = new ModelAndView("/query");
        modelAndView.addObject("uid", uid);
        modelAndView.addObject("did", did);
        modelAndView.addObject("nation", nation);
        modelAndView.addObject("city", city);
        return modelAndView;
    }
}
